package ui.panel.trains
{

	import flash.display.Sprite;
	
	import globals.ButtonType;
	
	import ui.component.Label;
	import ui.component.SeparationLine;
	import ui.component.TextButton;
	
	import util.UIUtil;

	public class TrainDetail extends Sprite
	{
		private var basicTrain:TrainInfo;
		private var expertTrain:TrainInfo;
		private var strongTrain:TrainInfo;
		private var speedTrain:TrainInfo;

		private var trainLabel:Label;
		private var condition:Label;//条件
		private var cdLabel:Label;//冷切时间
		private var speedButton:TextButton;

		public function TrainDetail()
		{
			basicTrain = new TrainInfo();
			basicTrain.x = 40;
			basicTrain.y = 30;
			basicTrain.update("train_1", "消费:100银币", "基本训练");
			addChild(basicTrain);

			expertTrain = new TrainInfo();
			expertTrain.x = 140;
			expertTrain.y = 30;
			expertTrain.update("train_2", "消费:2金币", "专家训练");
			addChild(expertTrain);
			　
			strongTrain = new TrainInfo();
			strongTrain.x = 240;
			strongTrain.y = 30;
			strongTrain.update("train_3", "消费:4金币", "强化训练");
			addChild(strongTrain);

			trainLabel = new Label(12, 0xFFFFFF);
			trainLabel.x = 40;
			trainLabel.y = 165;
			trainLabel.text = "双倍经验，还将训练7小时2分钟，已获得214经验";
			addChild(trainLabel);
			
			var sline:SeparationLine = new SeparationLine(310);
			sline.x = 15;
			sline.y = 190;
			this.addChild(sline);

			speedTrain = new TrainInfo();
			speedTrain.x = 40;
			speedTrain.y = 205;
			speedTrain.update("train_speed", "", "突飞猛进");
			addChild(speedTrain);

			condition = new Label(12, 0xFFFFFF);
			condition.width = 200;
			condition.wordWrap = condition.multiline = true;
			condition.x = 125;
			condition.y = 205;
			condition.text = "训练时间：立即完成\n消耗：1000功勋\n获得经验：290";
			addChild(condition);

			cdLabel = new Label(12, 0xFFFFFF);
			cdLabel.x = 125;
			cdLabel.y = 285;
			cdLabel.text = "冷切时间 00:01:20";
			addChild(cdLabel);

			speedButton = UIUtil.getTextButton(0,"加速",  ButtonType.BUTTON_YELLOW, speedHandler);
			speedButton.x = 245;
			speedButton.y = 280;
			addChild(speedButton);
		}

		private function speedHandler(buton:TextButton):void
		{

		}

		public function updateTrainText(text:String):void
		{
			trainLabel.text = text;
		}

		public function updateSpeedInfo(time:uint, cost:uint, exp:uint):void
		{
//			condition.text = "训练时间：" + time;
//			costLabel.text = "消耗：" + cost;
//			expLabel.text = "获得经验：" + exp;
		}

		public function updateCD(cd:uint):void
		{
			cdLabel.text = "冷却时间：" + cd;
		}

		public function clear():void
		{

		}
	}
}

import flash.display.Bitmap;
import flash.display.Sprite;

import globals.ButtonType;
import globals.Global;

import ui.component.Label;
import ui.component.TextButton;

import util.UIUtil;

class TrainInfo extends Sprite
{
	private var trainIcon:Bitmap;
	private var trainLabel:Label;
	private var trainButton:TextButton;

	public function TrainInfo()
	{
		trainIcon = new Bitmap();
		this.addChild(trainIcon);

		trainLabel = new Label(12, 0xFFFFFF);
		trainLabel.x = -2;
		trainLabel.y = 75;
		this.addChild(trainLabel);

		trainButton = UIUtil.getTextButton(0,"", ButtonType.BUTTON_GREEN, buttonHandler);
		trainButton.x = -2;
		trainButton.y = 100;
		this.addChild(trainButton);
	}

	private function buttonHandler(button:TextButton):void
	{

	}

	public function update(iconUrl:String, labelText:String, buttonText:String):void
	{
		trainIcon.bitmapData = Global.assetsManager.getAssetsAsBitmapData(iconUrl, "ui");
		trainLabel.text = labelText;
		trainButton.text = buttonText;
		if(labelText == "")
		{
			trainButton.y = 75;
		}
	}

	public function clear():void
	{

	}
}